//性别
function setLabels(el, element, value) {
    if($(el).hasClass('checked')) {
        return
    } else {
        $("#" + element).val(value)
        $(el).addClass('checked').siblings().removeClass('checked')
    }

}

// 额度指针旋转开始
(function() {
    var i = 0,
        times = 0,
        deg = -69,
        timer = null;
    timer = setInterval(function() {
        i++;
        deg += 7;
        var vbl = i * 2 / 140;
        var mo_num = parseInt((200000 - 0) * vbl);

        if(deg >= 65) {
            $(".pointer").css({
                transform: "rotate(65deg)"

            });
            $(".pointer .ball").css({
                top: "-0.28rem"
            })
            $(".eduNum").text(200000);
            $("body").css({
                "overflow-x": "hidden"
            })
            clearInterval(timer);
            return;
        }
        $(".pointer").css({
            transform: "rotate(" + deg + "deg)"
        })

        $(".eduNum").text(mo_num)
    }, 80)
})();



//判断数据
function checkParameterone() {
    if(!isCnName($("#username2").val())) {
        $("#username2").focus();
        alert("请正确填写用户名，以便我们方便联系您！");
        return false;
    }
    // console.log("ff", $("input[name='sex']").is(':checked'))
    if(!$("input[name='sex']").is(':checked')) {
        alert("请选择性别！");
        return false
    }
    if(!isPhoneNumber($("#mobile2").val())) {
        $("#mobile2").focus();
        alert("您的电话输入有误，请重新填写！");
        return false;
    }
    
    
    
    if($("#textcode").val().length !== 6) {
        $("#textcode").focus();
        alert("请正确输入验证码！");
        return false;
    }

    if($("#acceptsafety").val() == 0) {
        alert(" 请同意用户协议再提交！");
        return false;
    }
    var mobile = $("#mobile2").val(),
        code = $("#textcode").val();
    gsc.verifyCode(mobile, code, smsCodeCallback);

}

$(function() {

    $(".close,.sure").click(function() {
        $(".dk_popupContainer").fadeOut()
    });
    $("#safe").click(function() {
        $("#acceptsafety").val(1 - eval($("#acceptsafety").val()));
    });
})



//获取验证码
function sub() {
    if(!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test($("#mobile2").val())) || $("#mobile2").val().length !== 11) {
        $("#mobile2").focus();
        alert("您的电话输入有误，请重新填写！");
        return false;
    }
    $(".dk_popupContainer").fadeIn();
    var oCodeBtn = $("#getcode");
    oCodeBtn.css("backgroundColor", "#8a8888");
    oCodeBtn.attr("disabled", "disabled");
    //			oCodeBtn.attr("value", "1分钟后再试");
    var i = 60;

    var timer = setInterval(function() {
        if(i === 0) {
            clearInterval(timer);
            oCodeBtn.css("backgroundColor", "#27b3dc");
            oCodeBtn.removeAttr("disabled");
            oCodeBtn.attr("value", "获取验证码");
            return;
        }
        oCodeBtn.attr("value", "请" + i + "秒后再试");
        i--
    }, 1000);

    var mobile = $('#mobile2').val();
    gsc.getCode(mobile);
}

function smsCodeCallback(ret) {
    if(ret === 0) {
        finsubmit();
    } else {
        alert("验证码输入错误");
    }
}

